﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using ActionSystem.Core.Ranges;
using ActionSystem.Core.Utils;

namespace ActionSystem.Core.HitLogic
{
    public abstract class RangeBoxItem : BaseRangeBoxItem
    {
        const int HIT_RESULT_MAX_COUNT = 20;
        protected Collider hitBox=null;
        protected Collider[] hitRes = new Collider[HIT_RESULT_MAX_COUNT];

        public static new RangeBoxItem GetRangeBoxItem<T>() where T:RangeBoxItem
        {
            return GameObjectPool<T>.Create();
        }       

        public override void PoolItemReset()
        {
            if(hitBox==null)
            {
                hitBox = InitCollider();
                hitBox.isTrigger = true;
            }            
        }

        /// <summary>
        /// 生成当前box的碰撞器
        /// </summary>
        /// <returns>碰撞器</returns>
        public abstract Collider InitCollider();
        
        public Collider[] HitResult => hitRes;
    }
}

